<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>安装{$Think.config.INSTALL_PRODUCT_NAME}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__STATIC__/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/sweetalert/sweet-alert.min.css">
    <link href="__CSS__/install.css" rel="stylesheet">
    <!--[if lt IE 9]><script type="text/javascript" src="__STATIC__/jquery/jquery-1.11.1.min.js" charset="utf-8"></script><![endif]-->
    <!--[if gte IE 9]><!--><script type="text/javascript" src="__STATIC__/jquery/jquery-2.1.1.min.js" charset="utf-8"></script><!--<![endif]-->
    <script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/sweetalert/sweet-alert.min.js" charset="utf-8"></script>
</head>
<body>
    <div class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="sr-only">导航开关</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" target="_blank" href="{$Think.config.INSTALL_WEBSITE_DOMAIN}">{$Think.config.INSTALL_PRODUCT_NAME}</a>
            </div>
            <div class="collapse navbar-collapse nav-collapse">
                <ul class="nav navbar-nav" id="step">
                    <block name="header"></block>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="{$Think.config.INSTALL_WEBSITE_DOMAIN}" target="_blank">官网</a></li>
                    <li><a href="{$Think.config.INSTALL_WEBSITE_DOMAIN}" target="_blank">授权</a></li>
                </ul>
            </div>
        </div>
    </div>

    <div class="jumbotron masthead">
        <div class="container">
            <block name="body"></block>
        </div>
    </div>

    <footer class="footer navbar navbar-default navbar-fixed-bottom">
        <div class="container">
            <div>
                <block name="footer"></block>
                <a class="btn pull-right hidden-xs" href="{$Think.config.INSTALL_WEBSITE_DOMAIN}" target="_blank">{$Think.config.INSTALL_COMPANY_NAME}</a>
            </div>
        </div>
    </footer>

    <script type="text/javascript">
        //调整内容高度
        $(function(){
            $(window).resize(function(){
                $(".jumbotron").css("min-height", $(window).height() - 104);
            }).resize();
        });

        //ajax get请求
        $('.ajax-get').click(function(){
            var target;
            var that = this;
            if($(this).hasClass('confirm')){
                if(!confirm('确认要执行该操作吗?')){
                    return false;
                }
            }
            if((target = $(this).attr('href')) || (target = $(this).attr('url'))){
                $.get(target).success(function(data){
                    if(data.status == 1){
                        if (data.url) {
                            swal({
                                type: "success",
                                title: "Good job !",
                                text: data.info+ ' 页面即将自动跳转~',
                                timer: 1000
                            });
                        }else{
                            swal({
                                type: "success",
                                title: "Good job !",
                                text: data.info,
                                timer: 1000
                            });
                        }
                        setTimeout(function(){
                            if (data.url) {
                                location.href = data.url;
                            }else{
                                location.reload();
                            }
                        },1500);
                    }else{
                        swal({
                            type: "error",
                            title: "Oops...",
                            text: data.info,
                            timer: 2000
                        });
                        setTimeout(function(){
                            if (data.url) {
                                location.href = data.url;
                            }
                        },2000);
                    }
                });
            }
            return false;
        });

        //ajax post submit请求
        $('.ajax-post').click(function(){
            var target,query,form;
            var target_form = $(this).attr('target-form');
            var that = this;
            var nead_confirm=false;
            if(($(this).attr('type')=='submit') || (target = $(this).attr('href')) || (target = $(this).attr('url'))){
                form = $('.'+target_form);
                if($(this).attr('hide-data') === 'true'){ //无数据时也可以使用的功能
                    form = $('.hide-data');
                    query = form.serialize();
                }else if(form.get(0) == undefined){
                    return false;
                }else if(form.get(0).nodeName == 'FORM'){
                    if( $(this).hasClass('confirm')){
                        if(!confirm('确认要执行该操作吗?')){
                            return false;
                        }
                    }
                    if($(this).attr('url') !== undefined){
                        target = $(this).attr('url');
                    }else{
                        target = form.get(0).action;
                    }
                    query = form.serialize();
                }else if( form.get(0).nodeName=='INPUT' || form.get(0).nodeName=='SELECT' || form.get(0).nodeName=='TEXTAREA'){
                    form.each(function(k,v){
                        if(v.type=='checkbox' && v.checked==true){
                            nead_confirm = true;
                        }
                    })
                    if(nead_confirm && $(this).hasClass('confirm')){
                        if(!confirm('确认要执行该操作吗?')){
                            return false;
                        }
                    }
                    query = form.serialize();
                }else{
                    if($(this).hasClass('confirm')){
                        if(!confirm('确认要执行该操作吗?')){
                            return false;
                        }
                    }
                    query = form.find('input,select,textarea').serialize();
                }
                $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
                $.post(target,query).success(function(data){
                    if(data.status == 1){
                        if(data.url){
                            swal({
                                type: "success",
                                title: "Good job !",
                                text: data.info+ ' 页面即将自动跳转~',
                                timer: 1000
                            });
                        }else{
                            swal({
                                type: "success",
                                title: "Good job !",
                                text: data.info,
                                timer: 1000
                            });
                        }
                        setTimeout(function(){
                            $(that).removeClass('disabled').prop('disabled',false);
                            if (data.url) {
                                location.href = data.url;
                            }else{
                                location.reload();
                            }
                        },1500);
                    }else{
                        $(".reloadverify").click();
                        swal({
                            type: "error",
                            title: "Oops...",
                            text: data.info,
                            timer: 2000
                        });
                        setTimeout(function(){
                            $(that).removeClass('disabled').prop('disabled',false);
                            if (data.url) {
                                location.href = data.url;
                            }
                        },2000);
                    }
                });
            }
            return false;
        });
    </script>
</body>
</html>
